//
//  ShowImageController.m
//  PosApp
//
//  Created by 李英新 on 2018/12/20.
//  Copyright © 2018 李英新. All rights reserved.
//

#import "ShowImageController.h"
#import "BanKaUserNewsController.h"
#import "YHWEBController.h"

@interface ShowImageController ()

@property (weak, nonatomic) IBOutlet UIImageView *ShowImage;

@property (weak, nonatomic) IBOutlet UIButton *Btn01;
@property (weak, nonatomic) IBOutlet UIButton *Bnt02;

@end

@implementation ShowImageController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"信用卡办理";
    self.Btn01.layer.cornerRadius = self.Btn01.bounds.size.height/2;
    self.Btn01.layer.borderWidth = 1;
    self.Btn01.layer.borderColor = KRGBColor(250, 70, 50).CGColor;
    
    self.Bnt02.layer.cornerRadius = self.Bnt02.bounds.size.height/2;
    
    [self UpLoadImageData];
    
}

- (void)UpLoadImageData{
    NSMutableDictionary * dic = [[NSMutableDictionary alloc] init];
    [dic setObject:self.BKModel.bank_id forKey:@"id"];
    
    [MainObjectWay PostWithMethod:@"handle_detail" andAction:@"Handle" andAddParam:YES parameters:dic success:^(id responseObject) {
        NSLog(@"图片信息 = %@",responseObject);
        if ([MainObjectWay IsSucceedWithCode:responseObject[@"code"]]) {
            NSMutableDictionary * dic = responseObject[@"data"];
            NSString * ImageStr = [NSString stringWithFormat:@"%@",dic[@"bank_cont"]];
            [self.ShowImage sd_setImageWithURL:[NSURL URLWithString:ImageStr]];
            
            self.bank_pj = dic[@"bank_pj"];
        }
        
    } failure:^(NSError *error) {
        NSLog(@"错误信息 = %@",error);
    }];
}
- (IBAction)ClickOnBtn01ToPush:(id)sender {
    if ([self.bank_pj intValue] == 1) {
        [self zhiJiePush];
        return;
    }
    BanKaUserNewsController * UserNews = [[BanKaUserNewsController alloc] init];
    UserNews.BankID = self.BKModel.bank_id;
    UserNews.BankName = self.BKModel.bank_name;
    UserNews.bank_pj = self.bank_pj;
    [self.navigationController pushViewController:UserNews animated:YES];
    
}
- (IBAction)ClickOnBtn02ToPush:(id)sender {
    if ([self.bank_pj intValue] == 1) {
        [self zhiJiePush];
        return;
    }
    BanKaUserNewsController * UserNews = [[BanKaUserNewsController alloc] init];
    UserNews.BankID = self.BKModel.bank_id;
    UserNews.BankName = self.BKModel.bank_name;
    UserNews.bank_pj = self.bank_pj;
    [self.navigationController pushViewController:UserNews animated:YES];
}

- (void)zhiJiePush{
    if ([self.bank_pj intValue] == 1) {
        NSMutableDictionary * dic = [[NSMutableDictionary alloc] init];
        [dic setObject:KUserID forKey:@"member_id"];
        [dic setObject:self.self.BKModel.bank_id forKey:@"bank_id"];
        [dic setObject:self.BKModel.bank_name forKey:@"bank_name"];
        //        [dic setObject:self.CardUserName.text forKey:@"name"];
        //        [dic setObject:self.CardUseriPhone.text forKey:@"phone"];
        //        [dic setObject:self.CardUserSFNumg.text forKey:@"idcard"];
        
        [dic setObject:self.bank_pj forKey:@"bank_pj"];
        
        [MainObjectWay PostWithMethod:@"handle_submit" andAction:@"Handle" andAddParam:YES parameters:dic success:^(id responseObject) {
            NSLog(@"提交结果 = %@",responseObject);
            if ([MainObjectWay IsSucceedWithCode:responseObject[@"code"]]) {
                YHWEBController * WebC = [[YHWEBController alloc] init];
                WebC.title = self.BKModel.bank_name;
                WebC.WebStr = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"url"]];
                [self.navigationController pushViewController:WebC animated:YES];
                
            }
        } failure:^(NSError *error) {
            NSLog(@"错误信息 = %@",error);
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
